﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizCollegeWebApp.Models;

namespace BizCollegeUnitTests
{
    internal class TestUtility
    {
        internal static Course CreateTemporaryCourse()
        {
            BizCollegeDBDataContext db = new BizCollegeDBDataContext();
            Course testCourse = new Course()
            {
                CourseName = "Test Course",
                CourseDesciption = "Test Course Description",
                CourseStateID = db.GetUnderReviewCourseState()
            };
            db.Courses.InsertOnSubmit(testCourse);
            db.SubmitChanges();
            return testCourse;
        }

        internal static void CleanUpCourse(Course testCourse)
        {
            BizCollegeDBDataContext db = new BizCollegeDBDataContext();
            Course dbCourse = db.Courses.FirstOrDefault(c => c.CourseID == testCourse.CourseID);
            db.Courses.DeleteOnSubmit(dbCourse);
            db.SubmitChanges();
        }
   
    }
}
